﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Collections.Generic;

public class tbPointDB
{
    #region[tbPoint_Add]
    public static bool tbPoint_Add(tbPointDATA _tbPointDATA)
    {
        bool check = false;
        using (SqlConnection dbConn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
        {
            using (SqlCommand dbCmd = new SqlCommand("sp_tbPoint_Add", dbConn))
            {
                dbCmd.CommandType = CommandType.StoredProcedure;
                dbConn.Open();
                dbCmd.Parameters.Add(new SqlParameter("@criId", _tbPointDATA.criId));
                dbCmd.Parameters.Add(new SqlParameter("@point", _tbPointDATA.point));
                dbCmd.Parameters.Add(new SqlParameter("@poOrd", _tbPointDATA.poOrd));
                dbCmd.ExecuteNonQuery();
                dbConn.Close();
                check = true;
            }
        }
        return check;
    }
    #endregion
    #region[tbPoint_Update]
    public static bool tbPoint_Update(tbPointDATA _tbPointDATA)
    {
        bool check = false;
        using (SqlConnection dbConn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
        {
            using (SqlCommand dbCmd = new SqlCommand("sp_tbPoint_Update", dbConn))
            {
                dbCmd.CommandType = CommandType.StoredProcedure;
                dbConn.Open();
                dbCmd.Parameters.Add(new SqlParameter("@poId", _tbPointDATA.poId));
                dbCmd.Parameters.Add(new SqlParameter("@criId", _tbPointDATA.criId));
                dbCmd.Parameters.Add(new SqlParameter("@point", _tbPointDATA.point));
                dbCmd.Parameters.Add(new SqlParameter("@poOrd", _tbPointDATA.poOrd));
                dbCmd.ExecuteNonQuery();
                dbConn.Close();
                check = true;
            }
        }
        return check;
    }
    #endregion
    #region[tbPoint_Delete]
    public static bool tbPoint_Delete(string poId)
    {
        bool check = false;
        using (SqlConnection dbConn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
        {
            using (SqlCommand dbCmd = new SqlCommand("sp_tbPoint_Delete", dbConn))
            {
                dbCmd.CommandType = CommandType.StoredProcedure;
                dbCmd.Parameters.Add(new SqlParameter("@poId", poId));
                dbConn.Open();
                dbCmd.ExecuteNonQuery();
                dbConn.Close();
                check = true;
            }
        }
        return check;
    }
    #endregion
    #region[tbPoint_GetByAll]
    public static List<tbPointDATA> tbPoint_GetByAll()
    {
        List<tbPointDATA> list = new List<tbPointDATA>();
        using (SqlConnection dbConn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
        {
            using (SqlCommand dbCmd = new SqlCommand("sp_tbPoint_GetByAll", dbConn))
            {
                dbCmd.CommandType = CommandType.StoredProcedure;
                dbConn.Open();
                using (SqlDataReader reader = dbCmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        tbPointDATA objtbPointDATA = new tbPointDATA(
                        reader["poId"].ToString(),
                        reader["criId"].ToString(),
                        reader["point"].ToString(),
                        reader["poOrd"].ToString(),
                        reader["criName"].ToString());
                        list.Add(objtbPointDATA);
                    }
                }
                dbConn.Close();
            }
        }
        return list;
    }
    #endregion
    #region[tbPoint_GetByID]
    public static List<tbPointDATA> tbPoint_GetByID(string poId)
    {
        List<tbPointDATA> list = new List<tbPointDATA>();
        using (SqlConnection dbConn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
        {
            using (SqlCommand dbCmd = new SqlCommand("sp_tbPoint_GetByID", dbConn))
            {
                dbCmd.CommandType = CommandType.StoredProcedure;
                dbConn.Open();
                dbCmd.Parameters.Add(new SqlParameter("@poId", poId));
                using (SqlDataReader reader = dbCmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        tbPointDATA objtbPointDATA = new tbPointDATA(
                        reader["poId"].ToString(),
                        reader["criId"].ToString(),
                        reader["point"].ToString(),
                        reader["poOrd"].ToString(),
                        reader["criName"].ToString());
                        list.Add(objtbPointDATA);
                    }
                }
                dbConn.Close();
            }
        }
        return list;
    }
    #endregion
    #region[tbPoint_GetBycriId]
    public static List<tbPointDATA> tbPoint_GetBycriId(string criId)
    {
        List<tbPointDATA> list = new List<tbPointDATA>();
        using (SqlConnection dbConn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
        {
            using (SqlCommand dbCmd = new SqlCommand("sp_tbPoint_GetBycriId", dbConn))
            {
                dbCmd.CommandType = CommandType.StoredProcedure;
                dbConn.Open();
                dbCmd.Parameters.Add(new SqlParameter("@criId", criId));
                using (SqlDataReader reader = dbCmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        tbPointDATA objtbPointDATA = new tbPointDATA(
                        reader["poId"].ToString(),
                        reader["criId"].ToString(),
                        reader["point"].ToString(),
                        reader["poOrd"].ToString(),
                        reader["criName"].ToString());
                        list.Add(objtbPointDATA);
                    }
                }
                dbConn.Close();
            }
        }
        return list;
    }
    #endregion
}
